<template>
  <svg
    :class="svgClass"
    v-bind="$attrs"
    :style="{ color: color, fontSize: size + 'px' }"
  >
    <use :href="iconName"></use>
  </svg>
</template>

<script setup>
import { computed } from 'vue'
const props = defineProps({
  iconClass: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: ''
  },
  size: {
    type: Number
  }
})
const iconName = computed(() => `#icon-${props.iconClass}`)
const svgClass = computed(() => {
  if (props.iconClass) return `svg-icon icon-${props.iconClass}`
  return 'svg-icon'
})
</script>

<style scoped>
.svg-icon {
  width: 1.15em;
  height: 1.15em;
  overflow: hidden;
  vertical-align: -0.15em;
  fill: currentColor;
}
</style>
